package org.dslmagic;

import org.dslmagic.demo.MyInterpreter;
import org.dslmagic.dsl.Dsl;
import org.dslmagic.holder.ClassHolder;
import org.dslmagic.holder.ObjectHolder;


public class DataManipulationDsl {

	public static final Dsl $$ = Dsl.create("$$");
	public static final Dsl $ = Dsl.create("$");
	public static final Dsl $1 = Dsl.create("$1");
	public static final Dsl $2 = Dsl.create("$2");
	public static final Dsl $3 = Dsl.create("$3");
	public static final Dsl $4 = Dsl.create("$4");
	public static final Dsl $5 = Dsl.create("$5");
	public static final Dsl $6 = Dsl.create("$6");
	public static final Dsl $7 = Dsl.create("$7");
	public static final Dsl $8 = Dsl.create("$8");
	public static final Dsl $9 = Dsl.create("$9");

	private static Class<MyInterpreter> interpreterClass;

	public static void $interpreter(Class<MyInterpreter> interpreterClass) {
		DataManipulationDsl.interpreterClass = interpreterClass;
	}

	public static <T> ClassHolder<T> $(Class<T> clazz) {
		return new ClassHolder<T>(clazz);
	}

	public static <T> ObjectHolder<T> $(T object) {
		return new ObjectHolder<T>(object);
	}

	private static Dsl createDSL(String name, Object... args) {
		return Dsl.create(name, interpreterClass, args);
	}

	private static Dsl createDSL(String name, Dsl... dsls) {
		return Dsl.create(name, interpreterClass, (Object[]) dsls);
	}

	public static Dsl get(Object target, Object key) {
		return createDSL("get", target, key);
	}

	public static Dsl println(Object value) {
		return createDSL("println", value);
	}

	public static Dsl like(Object value1, Object value2) {
		return createDSL("like", value1, value2);
	}

	public static Dsl eq(Object value1, Object value2) {
		return createDSL("eq", value1, value2);
	}

	public static Dsl neq(Object value1, Object value2) {
		return createDSL("neq", value1, value2);
	}

	public static Dsl lt(Object value1, Object value2) {
		return createDSL("lt", value1, value2);
	}

	public static Dsl lte(Object value1, Object value2) {
		return createDSL("lte", value1, value2);
	}

	public static Dsl gt(Object value1, Object value2) {
		return createDSL("gt", value1, value2);
	}

	public static Dsl gte(Object value1, Object value2) {
		return createDSL("gte", value1, value2);
	}

	public static Dsl test(Dsl value, Dsl predicate) {
		return createDSL("test", value, predicate);
	}

	public static Dsl and(Dsl... bools) {
		return createDSL("and", bools);
	}

	public static Dsl or(Dsl... bools) {
		return createDSL("or", bools);
	}

	public static Dsl xor(Dsl... bools) {
		return createDSL("xor", bools);
	}

	public static Dsl size(Object value) {
		return createDSL("size", value);
	}

	public static Dsl filter(Dsl criterium, Object[] values) {
		return createDSL("filter", criterium, values);
	}

	public static Dsl filter(Dsl criterium, Dsl values) {
		return createDSL("filter", criterium, values);
	}

	public static Dsl compare(Object evaluation) {
		return createDSL("compare", evaluation);
	}
	
	public static Dsl call(String method, Object... arguments) {
		return createDSL("call", method, arguments);
	}
	
	public static Dsl call(Dsl method, Object... arguments) {
		return createDSL("call", method, arguments);
	}


}
